package ntancnit.app.whereareyou;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;

public class DialogAlert extends Activity {

	private Context context;
	private String friendName, lat, lng, content;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		context = DialogAlert.this;
		lat = getIntent().getStringExtra("lat");
		lng = getIntent().getStringExtra("lng");
		friendName = getIntent().getStringExtra("name");
		content = getIntent().getStringExtra("content");

		AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
				context);
		alertDialogBuilder.setTitle("\"Where are you.?\" "+getString(R.string.notify));
		alertDialogBuilder
				.setMessage(
						"\""
								+ friendName
								+ "\""
								+ getString(R.string.notifyContent))
				.setCancelable(false)
				.setPositiveButton(getString(R.string.ok),
						new DialogInterface.OnClickListener() {
							public void onClick(DialogInterface dialog, int id) {
								Intent intent = new Intent(context,
										FriendActivity.class);
								intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
								intent.putExtra("lat", lat);
								intent.putExtra("lng", lng);
								intent.putExtra("content", content);
								intent.putExtra("name", friendName);
								context.startActivity(intent);
								dialog.dismiss();
								finish();
							}
						})
				.setNegativeButton(getString(R.string.cancel),
						new DialogInterface.OnClickListener() {
							public void onClick(DialogInterface dialog, int id) {
								dialog.dismiss();
								finish();
							}
						});
		AlertDialog alertDialog = alertDialogBuilder.create();
		alertDialog.show();
	}

}
